package com.jwdf.uda.http.action;

import android.content.Context;

import com.jwdf.uda.bean.PbBean;
import com.jwdf.uda.http.AHttpService;
import com.jwdf.uda.http.ApiService;

import retrofit2.Call;

/**
 * Created by Administrator on 2016/9/21.
 */
public class QuizAddVoteAction extends AHttpService<PbBean.PbResQuestionAddVote> {
    private int quizId;
    private PbBean.PbSignBaseVoteOptionType optionId;

    private QuizAddVoteAction(Context context, int quizId, PbBean.PbSignBaseVoteOptionType optionId) {
        super(context);
        this.quizId = quizId;
        this.optionId = optionId;
    }

    public static QuizAddVoteAction newInstance(Context context, int quizId, PbBean.PbSignBaseVoteOptionType optionId) {
        return new QuizAddVoteAction(context, quizId, optionId);
    }

    @Override
    protected Call newRetrofitCall(ApiService apiService, PbBean.PbBaseClientInfo.Builder baseBuilder) {
        PbBean.PbReqQuestionAddVote.Builder builder = PbBean.PbReqQuestionAddVote.newBuilder();
        builder.setBaseClientInfo(baseBuilder);
        builder.setQuestionId(quizId);
        builder.setVoteOption(optionId);

        return apiService.quizVoteAdd(builder.build());
    }
}
